document.addEventListener("DOMContentLoaded", function() {
    const accordionHeaders = document.querySelectorAll('.accordion-header');

    accordionHeaders.forEach(header => {
        header.addEventListener('click', function() {
            const accordionContent = this.nextElementSibling;
            const isOpen = accordionContent.style.maxHeight;

            // 关闭所有打开的菜单
            accordionHeaders.forEach(h => {
                h.nextElementSibling.style.maxHeight = null;
            });

            // 如果当前菜单是打开的，则关闭它；否则打开它
            if (isOpen) {
                accordionContent.style.maxHeight = null;
            } else {
                accordionContent.style.maxHeight = accordionContent.scrollHeight + "px";
            }
        });
    });
});